<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Blog," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="系统环境是CentOS 7 64位。
安装Nginx系统更新安装内置的EPEL源123yum install epel-releaserpm -Uvh https://rhel7.iuscommunity.org/ius-release.rpmrpm -Uvh https://centos7.iuscommunity.org/ius-release.rpm
安装中若是出现失败的情况只要多运行几次即">
<meta property="og:type" content="article">
<meta property="og:title" content="阿里云部署Ghost">
<meta property="og:url" content="http://www.vitah.net/posts/f331b204/index.html">
<meta property="og:site_name" content="Vitah's Blog">
<meta property="og:description" content="系统环境是CentOS 7 64位。
安装Nginx系统更新安装内置的EPEL源123yum install epel-releaserpm -Uvh https://rhel7.iuscommunity.org/ius-release.rpmrpm -Uvh https://centos7.iuscommunity.org/ius-release.rpm
安装中若是出现失败的情况只要多运行几次即">
<meta property="og:updated_time" content="2016-07-10T16:04:33.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="阿里云部署Ghost">
<meta name="twitter:description" content="系统环境是CentOS 7 64位。
安装Nginx系统更新安装内置的EPEL源123yum install epel-releaserpm -Uvh https://rhel7.iuscommunity.org/ius-release.rpmrpm -Uvh https://centos7.iuscommunity.org/ius-release.rpm
安装中若是出现失败的情况只要多运行几次即">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://www.vitah.net/posts/f331b204/"/>





  <title> 阿里云部署Ghost | Vitah's Blog </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  














  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Vitah's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocapitalize="off" autocomplete="off" autocorrect="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://www.vitah.net/posts/f331b204/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Vitah">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/head.JPG">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Vitah's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                阿里云部署Ghost
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-07-11T00:04:33+08:00">
                2016-07-11
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Blog/" itemprop="url" rel="index">
                    <span itemprop="name">Blog</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/posts/f331b204/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count"
                        data-disqus-identifier="posts/f331b204/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>系统环境是CentOS 7 64位。</p>
<h2 id="安装Nginx"><a href="#安装Nginx" class="headerlink" title="安装Nginx"></a>安装Nginx</h2><h3 id="系统更新"><a href="#系统更新" class="headerlink" title="系统更新"></a>系统更新</h3><h4 id="安装内置的EPEL源"><a href="#安装内置的EPEL源" class="headerlink" title="安装内置的EPEL源"></a>安装内置的EPEL源</h4><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">yum install epel-release</div><div class="line">rpm -Uvh https:<span class="comment">//rhel7.iuscommunity.org/ius-release.rpm</span></div><div class="line">rpm -Uvh https:<span class="comment">//centos7.iuscommunity.org/ius-release.rpm</span></div></pre></td></tr></table></figure>
<p>安装中若是出现失败的情况只要多运行几次即可。</p>
<h4 id="更新yum缓存"><a href="#更新yum缓存" class="headerlink" title="更新yum缓存"></a>更新yum缓存</h4><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">yum repolist</div></pre></td></tr></table></figure>
<a id="more"></a>
<h4 id="更新CentOS7内核和内置软件"><a href="#更新CentOS7内核和内置软件" class="headerlink" title="更新CentOS7内核和内置软件"></a>更新CentOS7内核和内置软件</h4><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">yum update -y</div></pre></td></tr></table></figure>
<p>更新需要一段时间，大概十分钟左右，完成后重启服务器，如果有其他项目正在运行，重启服务器要谨慎。同样更新中若是出现网络不可达失败等情况，多试几次即可。</p>
<h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><h4 id="配置Nginx-yum源"><a href="#配置Nginx-yum源" class="headerlink" title="配置Nginx yum源"></a>配置Nginx yum源</h4><p>新建并编辑Nginx yum源文件：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">vim /etc/yum.repos.d/nginx.repo</div></pre></td></tr></table></figure>
<p>进入vim编辑模式，在该文件中输入以下内容:</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">[nginx] </div><div class="line">name=nginx repo</div><div class="line">baseurl=http:<span class="comment">//nginx.org/packages/centos/$releasever/$basearch/ </span></div><div class="line">gpgcheck=<span class="number">0</span></div><div class="line">enabled=<span class="number">1</span></div></pre></td></tr></table></figure>
<p>然后保存。</p>
<h4 id="安装Nginx-1"><a href="#安装Nginx-1" class="headerlink" title="安装Nginx"></a>安装Nginx</h4><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">yum install nginx -y <span class="comment">// 安装Nginx</span></div><div class="line">systemctl enable nginx <span class="comment">// 设置Nginx随服务器启动而启动</span></div><div class="line">systemctl start nginx <span class="comment">// 启动Nginx</span></div><div class="line">systemctl status nginx <span class="comment">// 查看Nginx状态</span></div></pre></td></tr></table></figure>
<p>看到如下内容则说明启动成功：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)</div><div class="line">Active: active (running) since 一 <span class="number">2016</span><span class="number">-05</span><span class="number">-30</span> <span class="number">15</span>:<span class="number">31</span>:<span class="number">57</span> CST; <span class="number">6</span>s ago</div></pre></td></tr></table></figure>
<p>这时候在浏览器中输入阿里云的公网地址，可以看到Welcome o nginx!</p>
<h4 id="设置Nginx反向代理"><a href="#设置Nginx反向代理" class="headerlink" title="设置Nginx反向代理"></a>设置Nginx反向代理</h4><p>如果完成上一步并且在浏览器中看见Nginx的welcome，那么我们就可以开始配置反向代理，让代理从80端口指向2368端口，去到以下这个目录：<br><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">cd /etc/nginx/conf.d</div></pre></td></tr></table></figure></p>
<p>里面有一个default.conf的配置文件，删掉这个文件或者把这个文件里面的内容全部用#注释掉，填写新的内容:<br><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">server &#123;  </div><div class="line">    listen <span class="number">80</span>;</div><div class="line">    server_name zyden.vicp.cc; <span class="comment">// 自己的域名或者ip地址</span></div><div class="line">    location / &#123;</div><div class="line">        proxy_set_header   X-Real-IP $remote_addr;</div><div class="line">        proxy_set_header   Host      $http_host;</div><div class="line">        proxy_pass         http:<span class="comment">//127.0.0.1:2368;</span></div><div class="line">        proxy_set_header REMOTE-HOST $remote_addr;</div><div class="line">        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>保存退出，并重启nginx：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">service nginx restart</div></pre></td></tr></table></figure>
<p><br></p>
<hr>
<h2 id="安装Mysql"><a href="#安装Mysql" class="headerlink" title="安装Mysql"></a>安装Mysql</h2><h3 id="错误的安装方法"><a href="#错误的安装方法" class="headerlink" title="错误的安装方法"></a>错误的安装方法</h3><p>使用常规的命令：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">yum -y install mysql mysql-server mysql-devel</div></pre></td></tr></table></figure>
<p>安装时不会安装Mysql数据库，而是安装离mariadb数据。因为在CentOS 7和CentOS 7.1系统中，默认安装的mysql是它的分支mariadb。这里引用下百度百科关于mariadb的描述：</p>
<blockquote>
<p>MariaDB数据库管理系统是MySQL的一个分支，主要由开源社区在维护，采用GPL授权许可 MariaDB的目的是完全兼容MySQL，包括API和命令行，使之能轻松成为MySQL的代替品。开发这个分支的原因之一时：甲骨文公司收购了Mysql后，有将Mysql闭源的潜在风险，因此社区采用分支的方式来避开这个风险。</p>
</blockquote>
<h3 id="正确的安装方法"><a href="#正确的安装方法" class="headerlink" title="正确的安装方法"></a>正确的安装方法</h3><p>Linux系统自带的repo是不会自动更新每个软件的最新版本（基本都是比较靠后的稳定版），所以无法通过yum方式安装MySQL的高级版本。所以我们需要先安装带有当前可用的mysql5系列社区版资源的rpm包。</p>
<h4 id="安装rpm包："><a href="#安装rpm包：" class="headerlink" title="安装rpm包："></a>安装rpm包：</h4><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">rpm -Uvh http:<span class="comment">//dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm</span></div></pre></td></tr></table></figure>
<h4 id="查看当前可用的Mysql安装资源："><a href="#查看当前可用的Mysql安装资源：" class="headerlink" title="查看当前可用的Mysql安装资源："></a>查看当前可用的Mysql安装资源：</h4><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@iZ23dnc7nkxZ ~]<span class="meta"># yum repolist enabled | grep <span class="meta-string">"mysql.*-community.*"</span></span></div></pre></td></tr></table></figure>
<p>输出内容：<br><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">mysql-connectors-community/x86_64 MySQL Connectors Community                  <span class="number">21</span></div><div class="line">mysql-tools-community/x86_64      MySQL Tools Community                       <span class="number">33</span></div><div class="line">mysql56-community/x86_64          MySQL <span class="number">5.6</span> Community Server                 <span class="number">229</span></div></pre></td></tr></table></figure></p>
<p>从上面列表可以看出mysql56-community/x86_64和MySQL 5.6 Community Server可以使用。</p>
<h4 id="直接用yum方式安装Mysql5-6版本"><a href="#直接用yum方式安装Mysql5-6版本" class="headerlink" title="直接用yum方式安装Mysql5.6版本"></a>直接用yum方式安装Mysql5.6版本</h4><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">yum -y install mysql-community-server</div></pre></td></tr></table></figure>
<p>等待安装完成即可。</p>
<h3 id="安装后的设置"><a href="#安装后的设置" class="headerlink" title="安装后的设置"></a>安装后的设置</h3><h4 id="启动mysql："><a href="#启动mysql：" class="headerlink" title="启动mysql："></a>启动mysql：</h4><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">systemctl start mysqld</div></pre></td></tr></table></figure>
<h4 id="设置为开机启动"><a href="#设置为开机启动" class="headerlink" title="设置为开机启动"></a>设置为开机启动</h4><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">systemctl enable mysqld</div></pre></td></tr></table></figure>
<h4 id="添加相关的mysql配置："><a href="#添加相关的mysql配置：" class="headerlink" title="添加相关的mysql配置："></a>添加相关的mysql配置：</h4><figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">Enter current password for root (enter for none): //提示输入当前的root密码，还未设置，直接Enter即可</div><div class="line">Set root password? [Y/n] y // 输入y并设置root密码</div><div class="line">Remove anonymous users? [Y/n] y //删除匿名用户</div><div class="line">Disallow root login remotely? [Y/n] y // 禁止root远程登录</div><div class="line">Remove test database and access to it? [Y/n] y // 删除test测试数据库</div><div class="line">Reload privilege tables now? [Y/n] y // 刷新权限</div></pre></td></tr></table></figure>
<h4 id="设置支持中文的配置"><a href="#设置支持中文的配置" class="headerlink" title="设置支持中文的配置"></a>设置支持中文的配置</h4><p>编辑Mysql的配置文件:</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">vi /etc/my.cnf</div></pre></td></tr></table></figure>
<p>在对应位置加上对应内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">[client]</div><div class="line"><span class="keyword">default</span>-character-<span class="built_in">set</span>=utf8  </div><div class="line">[mysql]</div><div class="line"><span class="keyword">default</span>-character-<span class="built_in">set</span>=utf8  </div><div class="line">[mysqld]</div><div class="line">character-<span class="built_in">set</span>-server=utf8</div><div class="line">collation-server=utf8_general_ci</div></pre></td></tr></table></figure>
<h4 id="新建一个ghost专用的mysql用户和专用的database："><a href="#新建一个ghost专用的mysql用户和专用的database：" class="headerlink" title="新建一个ghost专用的mysql用户和专用的database："></a>新建一个ghost专用的mysql用户和专用的database：</h4><p>(1) 先登录root账户：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">mysql -u root -p <span class="comment">// 用root用户登录mysql</span></div></pre></td></tr></table></figure>
<p>(2) 创建ghost数据库：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">create databse ghost;</div></pre></td></tr></table></figure>
<p>创建之后可以通过以下命令查看数据库是否创建成功:</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">show databases;</div></pre></td></tr></table></figure>
<p>运行结果：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">mysql&gt; show databases;</div><div class="line">+--------------------+</div><div class="line">| Database           |</div><div class="line">+--------------------+</div><div class="line">| information_schema |</div><div class="line">| ghost              |</div><div class="line">| mysql              |</div><div class="line">| performance_schema |</div><div class="line">+--------------------+</div><div class="line"><span class="number">4</span> <span class="function">rows in <span class="title">set</span> <span class="params">(<span class="number">0.00</span> sec)</span></span></div></pre></td></tr></table></figure>
<p>可以看到已经创建成功。</p>
<p>(3) 创建ghost用户：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">create user ghost;</div></pre></td></tr></table></figure>
<p>然后通过下述命令查看是否创建成功：</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;</div></pre></td></tr></table></figure>
<p>运行结果：</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">mysql&gt; SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;</div><div class="line">+---------------------------+</div><div class="line">| query                     |</div><div class="line">+---------------------------+</div><div class="line">| User: 'ghost'@'%';        |</div><div class="line">| User: 'root'@'127.0.0.1'; |</div><div class="line">| User: 'root'@'::1';       |</div><div class="line">| User: 'root'@'localhost'; |</div><div class="line">+---------------------------+</div><div class="line">4 rows in set (0.00 sec)</div></pre></td></tr></table></figure>
<p>可以看到ghost用户已经创建成功，％表示能被所有地址访问。</p>
<p>(4) 为用户ghost授权：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">mysql&gt; grant all privileges on ghost.* to ghost@<span class="string">'%'</span>;</div><div class="line">Query OK, <span class="number">0</span> <span class="function">rows <span class="title">affected</span> <span class="params">(<span class="number">0.00</span> sec)</span></span></div></pre></td></tr></table></figure>
<p>通过命令查看用户ghost的权限状态：</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">mysql&gt; show grants for ghost@'%';</div><div class="line">+--------------------------------------------------+</div><div class="line">| Grants for ghost@%                               |</div><div class="line">+--------------------------------------------------+</div><div class="line">| GRANT USAGE ON *.* TO 'ghost'@'%'                |</div><div class="line">| GRANT ALL PRIVILEGES ON `ghost`.* TO 'ghost'@'%' |</div><div class="line">+--------------------------------------------------+</div><div class="line">2 rows in set (0.00 sec)</div></pre></td></tr></table></figure>
<p>这时候我们还需要为ghost用户设置密码，在shell环境下，输入以下命令：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">root@iZ23dnc7nkxZ ~]<span class="meta"># mysqladmin -u ghost password <span class="meta-string">"xxxxxxxx"</span></span></div></pre></td></tr></table></figure>
<p>提示 <code>arning: Using a password on the command line interface can be insecure.</code>即设置成功。设置用户密码有多种方法，可以自行搜索。</p>
<p><br></p>
<h2 id="安装Node-js"><a href="#安装Node-js" class="headerlink" title="安装Node.js"></a>安装Node.js</h2><p>有多种方法，下面介绍源码安装方案：</p>
<h3 id="下载源码："><a href="#下载源码：" class="headerlink" title="下载源码："></a>下载源码：</h3><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">wget http:<span class="comment">//nodejs.org/dist/v0.10.40/node-v0.10.40.tar.gz</span></div></pre></td></tr></table></figure>
<h3 id="解压源码："><a href="#解压源码：" class="headerlink" title="解压源码："></a>解压源码：</h3><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tar xzvf node-v* &amp;&amp; cd node-v*</div></pre></td></tr></table></figure>
<h3 id="安装必要的编译软件"><a href="#安装必要的编译软件" class="headerlink" title="安装必要的编译软件"></a>安装必要的编译软件</h3><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">yum install gcc gcc-c++</div></pre></td></tr></table></figure>
<h3 id="编译"><a href="#编译" class="headerlink" title="编译"></a>编译</h3><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">./configure</div><div class="line">make</div></pre></td></tr></table></figure>
<h3 id="编译-amp-安装"><a href="#编译-amp-安装" class="headerlink" title="编译&amp;安装"></a>编译&amp;安装</h3><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">make install</div></pre></td></tr></table></figure>
<h3 id="查看版本（测试安装是否成功）"><a href="#查看版本（测试安装是否成功）" class="headerlink" title="查看版本（测试安装是否成功）"></a>查看版本（测试安装是否成功）</h3><figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">node --version</div></pre></td></tr></table></figure>
<p><br></p>
<h2 id="安装Ghost"><a href="#安装Ghost" class="headerlink" title="安装Ghost"></a>安装Ghost</h2><h3 id="下载中文版的Ghost"><a href="#下载中文版的Ghost" class="headerlink" title="下载中文版的Ghost"></a>下载中文版的Ghost</h3><p>将ghost安装在/var/www目录下，没有该目录则创建:</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line"><span class="comment">// 创建该目录</span></div><div class="line">cd /var</div><div class="line">mkdir www</div><div class="line">cd /var/www</div><div class="line"></div><div class="line"><span class="comment">// 下载中文版ghost</span></div><div class="line">wget http:<span class="comment">//dl.ghostchina.com/Ghost-0.7.4-zh-full.zip</span></div><div class="line"></div><div class="line"><span class="comment">// 解压为ghost文件夹</span></div><div class="line">unzip Ghost<span class="number">-0.7</span><span class="number">.4</span>-zh-full.zip -d ghost</div><div class="line"></div><div class="line">cd ghost</div></pre></td></tr></table></figure>
<h3 id="修改生产环境的配置"><a href="#修改生产环境的配置" class="headerlink" title="修改生产环境的配置"></a>修改生产环境的配置</h3><p>这里要将config.example.js重命名为config.js再对其进行修改配置：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">mv config.example.js config.js </div><div class="line">vi config.js</div></pre></td></tr></table></figure>
<p>我们找到生产环境的配置：production</p>
<blockquote>
<p>Ghost-0.7.4-zh-full这个版本默认集成 sqlite3 原生库，但博客篇幅比较大时，sqlite读写数据量太大时将会影响页面加载速度，我们可以根据个人需求改用mysql<br>如果选择使用sqlite则在config.js中只需要修改url地址<br>修改production中的配置，把mysql中的配置注释去掉并修改，注释sqlite3中的配置:</p>
</blockquote>
<figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line">production: &#123;  </div><div class="line">    url: 'XXX.XXX.XXX.XXX', //这里是你自己主机的域名，或者IP</div><div class="line">    mail: &#123;&#125;,</div><div class="line">    database: &#123;</div><div class="line">        client: 'mysql'这里我选择使用mysql作为我博客的数据库</div><div class="line">        connection: &#123;</div><div class="line">            host     : '127.0.0.1',</div><div class="line">            user     : 'ghost', //mysql用户名</div><div class="line">            password : 'XX', //密码</div><div class="line">            database : 'ghost', //之前创建的ghost数据库名称</div><div class="line">            charset  : 'utf8'</div><div class="line">        &#125;,</div><div class="line">    server: &#123;</div><div class="line">            host: '127.0.0.1',</div><div class="line">            port: '2368'//若修改该端口记得在nginx中做相应改变</div><div class="line">        &#125;</div><div class="line">    &#125;</div></pre></td></tr></table></figure>
<p>修改后用命令<code>npm start -production</code>启动开发者模式的Ghost，然后在浏览器中输入ip地址或者域名，如果能看见Ghost则说明配置成功。</p>
<h3 id="守护Ghost进程"><a href="#守护Ghost进程" class="headerlink" title="守护Ghost进程"></a>守护Ghost进程</h3><p>只要我们一断开ssh，Ghost的进程就会被关闭，这里我们使用pm2来守护Ghost服务进程，并让其运行在生产模式production上:</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">npm install pm2 -g</div><div class="line">cd /var/wwwroot/ghost</div><div class="line">NODE_ENV=production pm2 start index.js --name <span class="string">"ghost"</span> <span class="comment">// //让ghost以production模式运作，指定程序的入口index.js，并且此进程命名为ghost</span></div><div class="line">pm2 startup centos <span class="comment">// 开机启动 </span></div><div class="line">pm2 save</div></pre></td></tr></table></figure>
<p>运行上面的命名，这样Ghost就可以运行在后台了。pm2要安装在全局，不然会提示问题。</p>
<p>pm2相关命令：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">pm2 restart 进程名</div></pre></td></tr></table></figure>

      
    </div>
    
    <div>
      
        
<div class="my_post_copyright">
  <script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>
  
  <!-- JS库 sweetalert 可修改路径 -->
  <script type="text/javascript" src="http://jslibs.wuxubj.cn/sweetalert_mini/jquery-1.7.1.min.js"></script>
  <script src="http://jslibs.wuxubj.cn/sweetalert_mini/sweetalert.min.js"></script>
  <link rel="stylesheet" type="text/css" href="http://jslibs.wuxubj.cn/sweetalert_mini/sweetalert.mini.css">

  <p><span>本文标题:</span><a href="/posts/f331b204/">阿里云部署Ghost</a></p>
  <p><span>文章作者:</span><a href="/" title="访问 Vitah 的个人博客">Vitah</a></p>
  <p><span>发布时间:</span>2016年07月11日 - 00:07</p>
  <p><span>最后更新:</span>2016年07月11日 - 00:07</p>
  <p><span>原始链接:</span><a href="/posts/f331b204/" title="阿里云部署Ghost">http://www.vitah.net/posts/f331b204/</a>
    <span class="copy-path"  title="点击复制文章链接"><i class="fa fa-clipboard" data-clipboard-text="http://www.vitah.net/posts/f331b204/"  aria-label="复制成功！"></i></span>
  </p>
  <p><span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
</div>

<script> 
    var clipboard = new Clipboard('.fa-clipboard');
	clipboard.on('success', $(function(){
	  $(".fa-clipboard").click(function(){
		swal({   
		  title: "",   
		  text: '复制成功',   
		  html: false,
		  timer: 500,   
		  showConfirmButton: false
	    });
	  });
    }));  
</script>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div></div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="/images/wechatpay.jpeg" alt="Vitah WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="/images/alipay.jpeg" alt="Vitah Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Blog/" rel="tag"># Blog</a>
          
        </div>
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/posts/6cc1d170/" rel="prev" title="expect用法">
                expect用法 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="disqus_thread">
        <noscript>
          Please enable JavaScript to view the
          <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a>
        </noscript>
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/head.JPG"
               alt="Vitah" />
          <p class="site-author-name" itemprop="name">Vitah</p>
           
              <p class="site-description motion-element" itemprop="description">深自缄默，如云漂泊。</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">47</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">13</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">14</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/vitahlin" target="_blank" title="Github">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  Github
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="mailto:linw1225@163.com" target="_blank" title="Mail">
                  
                    <i class="fa fa-fw fa-envelope"></i>
                  
                  Mail
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-block">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              友情链接
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="https://shuge.org/" title="书格" target="_blank">书格</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://taozj.org/" title="taozj" target="_blank">taozj</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://oserror.com/" title="Charles" target="_blank">Charles</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.hsmouc.com/" title="Hsmouc" target="_blank">Hsmouc</a>
                </li>
              
            </ul>
          </div>
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#安装Nginx"><span class="nav-number">1.</span> <span class="nav-text">安装Nginx</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#系统更新"><span class="nav-number">1.1.</span> <span class="nav-text">系统更新</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#安装内置的EPEL源"><span class="nav-number">1.1.1.</span> <span class="nav-text">安装内置的EPEL源</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#更新yum缓存"><span class="nav-number">1.1.2.</span> <span class="nav-text">更新yum缓存</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#更新CentOS7内核和内置软件"><span class="nav-number">1.1.3.</span> <span class="nav-text">更新CentOS7内核和内置软件</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#安装"><span class="nav-number">1.2.</span> <span class="nav-text">安装</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#配置Nginx-yum源"><span class="nav-number">1.2.1.</span> <span class="nav-text">配置Nginx yum源</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#安装Nginx-1"><span class="nav-number">1.2.2.</span> <span class="nav-text">安装Nginx</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#设置Nginx反向代理"><span class="nav-number">1.2.3.</span> <span class="nav-text">设置Nginx反向代理</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#安装Mysql"><span class="nav-number">2.</span> <span class="nav-text">安装Mysql</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#错误的安装方法"><span class="nav-number">2.1.</span> <span class="nav-text">错误的安装方法</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#正确的安装方法"><span class="nav-number">2.2.</span> <span class="nav-text">正确的安装方法</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#安装rpm包："><span class="nav-number">2.2.1.</span> <span class="nav-text">安装rpm包：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#查看当前可用的Mysql安装资源："><span class="nav-number">2.2.2.</span> <span class="nav-text">查看当前可用的Mysql安装资源：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#直接用yum方式安装Mysql5-6版本"><span class="nav-number">2.2.3.</span> <span class="nav-text">直接用yum方式安装Mysql5.6版本</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#安装后的设置"><span class="nav-number">2.3.</span> <span class="nav-text">安装后的设置</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#启动mysql："><span class="nav-number">2.3.1.</span> <span class="nav-text">启动mysql：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#设置为开机启动"><span class="nav-number">2.3.2.</span> <span class="nav-text">设置为开机启动</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#添加相关的mysql配置："><span class="nav-number">2.3.3.</span> <span class="nav-text">添加相关的mysql配置：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#设置支持中文的配置"><span class="nav-number">2.3.4.</span> <span class="nav-text">设置支持中文的配置</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#新建一个ghost专用的mysql用户和专用的database："><span class="nav-number">2.3.5.</span> <span class="nav-text">新建一个ghost专用的mysql用户和专用的database：</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#安装Node-js"><span class="nav-number">3.</span> <span class="nav-text">安装Node.js</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#下载源码："><span class="nav-number">3.1.</span> <span class="nav-text">下载源码：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#解压源码："><span class="nav-number">3.2.</span> <span class="nav-text">解压源码：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#安装必要的编译软件"><span class="nav-number">3.3.</span> <span class="nav-text">安装必要的编译软件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#编译"><span class="nav-number">3.4.</span> <span class="nav-text">编译</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#编译-amp-安装"><span class="nav-number">3.5.</span> <span class="nav-text">编译&安装</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#查看版本（测试安装是否成功）"><span class="nav-number">3.6.</span> <span class="nav-text">查看版本（测试安装是否成功）</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#安装Ghost"><span class="nav-number">4.</span> <span class="nav-text">安装Ghost</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#下载中文版的Ghost"><span class="nav-number">4.1.</span> <span class="nav-text">下载中文版的Ghost</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#修改生产环境的配置"><span class="nav-number">4.2.</span> <span class="nav-text">修改生产环境的配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#守护Ghost进程"><span class="nav-number">4.3.</span> <span class="nav-text">守护Ghost进程</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2015 - 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Vitah</span>
</div>



        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      访客
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      
    </span>
  

  
    <span class="site-pv">
      总访问量
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      
    </span>
  
</div>


        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  








  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  


  

    
      <script id="dsq-count-scr" src="https://http-www-vitah-net.disqus.com/count.js" async></script>
    

    
      <script type="text/javascript">
        var disqus_config = function () {
          this.page.url = 'http://www.vitah.net/posts/f331b204/';
          this.page.identifier = 'posts/f331b204/';
          this.page.title = '阿里云部署Ghost';
        };
        var d = document, s = d.createElement('script');
        s.src = 'https://http-www-vitah-net.disqus.com/embed.js';
        s.setAttribute('data-timestamp', '' + +new Date());
        (d.head || d.body).appendChild(s);
      </script>
    

  




	





  





  





  






  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
      search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.popup').toggle();
    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';
      $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = $( "entry", xmlResponse ).map(function() {
            return {
              title: $( "title", this ).text(),
              content: $("content",this).text(),
              url: $( "url" , this).text()
            };
          }).get();
          var $input = document.getElementById(search_id);
          var $resultContent = document.getElementById(content_id);
          $input.addEventListener('input', function(){
            var matchcounts = 0;
            var str='<ul class=\"search-result-list\">';
            var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
            $resultContent.innerHTML = "";
            if (this.value.trim().length > 1) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var content_index = [];
                var data_title = data.title.trim().toLowerCase();
                var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                var data_url = decodeURIComponent(data.url);
                var index_title = -1;
                var index_content = -1;
                var first_occur = -1;
                // only match artiles with not empty titles and contents
                if(data_title != '') {
                  keywords.forEach(function(keyword, i) {
                    index_title = data_title.indexOf(keyword);
                    index_content = data_content.indexOf(keyword);
                    if( index_title >= 0 || index_content >= 0 ){
                      isMatch = true;
                      if (i == 0) {
                        first_occur = index_content;
                      }
                    }

                  });
                }
                // show search results
                if (isMatch) {
                  matchcounts += 1;
                  str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                  var content = data.content.trim().replace(/<[^>]+>/g,"");
                  if (first_occur >= 0) {
                    // cut out 100 characters
                    var start = first_occur - 20;
                    var end = first_occur + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if(start == 0){
                      end = 50;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    var match_content = content.substring(start, end);
                    // highlight all keywords
                    keywords.forEach(function(keyword){
                      var regS = new RegExp(keyword, "gi");
                      match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                    });

                    str += "<p class=\"search-result\">" + match_content +"...</p>"
                  }
                  str += "</li>";
                }
              })};
            str += "</ul>";
            if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
            if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
            $resultContent.innerHTML = str;
          });
          proceedsearch();
        }
      });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>





  

  

  

  

  

</body>
</html>
